{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "335bccba",
   "metadata": {},
   "outputs": [],
   "source": [
    "import ZW_DC1000\n",
    "DC1000 = ZW_DC1000.DC1000()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "17d592bf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "255"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 连接根据硬件连接方式二选一\n",
    "# 以太网方式连接设备\n",
    "DC1000.ethernet_connect(\"192.168.2.22\", 8080)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "beaa6d98",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 串口方式连接设备\n",
    "DC1000.uart_connect(\"COM7\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "05b9a70f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "255"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 设置斜率 (斜率)  单位mV/s\n",
    "DC1000.set_slope(1000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c2991e46",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Open\n"
     ]
    }
   ],
   "source": [
    "# 检测设备在线状态，可以作为心跳使用\n",
    "if DC1000.check_device_status():\n",
    "    print(\"Open\")\n",
    "else:\n",
    "    print(\"Close\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ea82d5f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "255"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 打开通道 (通道)\n",
    "DC1000.open_ch(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "af453452",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 关闭通道 (通道)\n",
    "DC1000.close_ch(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5b8deeb1-ac75-4c34-9ee2-0f776ef9bc37",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "please open ch1\n",
      "Close\n"
     ]
    }
   ],
   "source": [
    "if(DC1000._check_status(1)):\n",
    "    print(\"Open\")\n",
    "else:\n",
    "    print(\"Close\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "afb5468d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "255"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 设置电压 (通道,电压，单位V)\n",
    "DC1000.set_vol(1,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0423d0d7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-3.2547e-08"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取电流 (通道)\n",
    "DC1000.get_current(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "f8cacc15",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取电流 (通道)\n",
    "DC1000.get_vol(7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f07a853",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 使能通道端接电阻 (通道,使能)\n",
    "DC1000.R_TERM(1, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "77593aff",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 使能通道端接电阻 (通道,使能)\n",
    "DC1000.R_TERM(1, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7fbe4d25",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 使能通道电流采集功能 (通道,使能)\n",
    "DC1000.IVDIS(1, 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7f163f69",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 改变设备IP, 不用重启设备，改变后自动生效 (IP)\n",
    "DC1000.change_ip(\"192.168.1.100\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  },
  "vscode": {
   "interpreter": {
    "hash": "bb4e2c62199a8c5b6497365215caa20505b39b538b5dbb952990bd2d6367dce4"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
